package tests;

import static org.junit.Assert.*;
import java.io.File;
import manager.FileManager;
import org.junit.Test;

public class FileManagerTests {

	String fn = "testfile.rcp";
	
	@Test
	public void testFileManager() {
		FileManager fm = new FileManager();
		assertNull(fm.getData());
	}

	@Test
	public void testFileManagerString() {
		@SuppressWarnings("unused")
		FileManager fm = new FileManager(fn);
		File tf = new File(FileManager.getDefaultRecipePath() + fn);
		
		assertTrue(tf.exists());
		tf.delete();
	}

	@Test
	public void testGetData() {
		FileManager fm = new FileManager(FileManager.getDefaultRecipePath() + fn);
		fm.createRecipe("test", "testing", "1 L milk", "directions", "", "file");
		assertTrue(fm.getData().getRecipeName().equals("test"));
		assertTrue(fm.getData().getCategory().equals("testing"));
		assertTrue(fm.getData().getListOfIngredientsAsString().equals("1 L milk"));
		assertTrue(fm.getData().getInstructions().equals("directions"));
	}

	@Test
	public void testCreateRecipe() {
		FileManager fm = new FileManager(FileManager.getDefaultRecipePath() + fn);
		fm.createRecipe("test", "testing", "1 L milk", "directions", "", "file");
		String rec = 
				"Recipe name: test\n" +
				"Category: testing\n" +
				"Image: \n" +
				"Tags: file\n" +
				"Ingredients: \n1 L milk\n" +
				"Directions: \ndirections";
		
		assertEquals("Strings should be equal", rec, fm.createString());
	}

	@Test
	public void testCreateString() {
		testCreateRecipe();
	}
}
